package com.hq.bootdemo.service.impl;

import com.hq.bootdemo.mapper.UserMapper;
import com.hq.bootdemo.service.UserService;
import com.yq.superMarket.test.MD5Util;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
   @Service
public class UserServiceImpl implements UserService {
    @Resource
    UserMapper userMapper;
    @Override
    public boolean login(UserEntity userEntity, HttpSession session){
        if(userEntity == null || userEntity.getUsername() == null ||userEntity.getPassword ==""
        || userEntity.getUsername() == null || userEntity.getUsername() =="") return false;
        UserEntity userData = userMapper.login(userEntity.getusername());
        if(userData !=null && userData.getPassword() !=null && userDate.getPassword().equals(MD5Util.getDigest(userEntity.getPassword()))){
            session.setAttribute("curUser", userData);
            return true;
        }
        return false;
    }
}
